import {busiHttp} from '../util/api';
import {HOME} from '../api/api';
import {PYTAT} from '../api/api.js'
import {ORDER} from '../api/api.js'
import {ORDERS} from '../api/api.js'
import {SHANGC} from '../api/api.js'
// function carousel(){
//   let params={}
//   return new Promise(function (resolve, reject) {
//       busiHttp(HOME.carousel, 'GET', params).then(res => {
//       resolve(res)
//     }).catch(err => {
//         reject(err)
//     })
//   })
// }
function today(params){
 
  return new Promise(function (resolve, reject) {
      busiHttp(ORDERS.today, 'GET',params).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}

function wxLogin(params){
  return new Promise(function (resolve, reject) {
      busiHttp(HOME.wxLogin, 'POST', params,false).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}

function bindwx(params){
  return new Promise(function (resolve, reject) {
      busiHttp(HOME.bindwx, 'POST', params,false).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}

function getVersion(params){
  return new Promise(function (resolve, reject) {
      busiHttp(HOME.version, 'GET', params,false).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}

function servicesList(params){
  return new Promise(function (resolve, reject) {
      busiHttp(HOME.servicesList, 'POST', params,false).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}

function login(params){
  return new Promise(function (resolve, reject) {
      busiHttp(HOME.login, 'POST', params,false).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}

function getlist(params){
  return new Promise(function (resolve, reject) {
      busiHttp(PYTAT.getlist, 'POST', params).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}


function getserve(params){
  return new Promise(function (resolve, reject) {
      busiHttp(PYTAT.getserve, 'GET', params).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}

function projectclick(id){
	console.log(id)
  return new Promise(function (resolve, reject) {
    let params={};
    let URL = PYTAT.projectclick+"/"+id;
	console.log(URL)
      busiHttp(URL, 'GET', params,true).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}

function tabs(params){
  return new Promise(function (resolve, reject) {
      busiHttp(ORDER.tabs, 'POST', params).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}

function preserve(params){
  return new Promise(function (resolve, reject) {
      busiHttp(PYTAT.preserve, 'POST', params).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}



function confirms(params){
  return new Promise(function (resolve, reject) {
      busiHttp(ORDERS.confirms, 'POST', params).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}

function offline(params){
  return new Promise(function (resolve, reject) {
      busiHttp(ORDERS.offline, 'POST', params,false).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}

function Immediately(params){
  return new Promise(function (resolve, reject) {
      busiHttp(ORDER.Immediately, 'POST', params).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}


function getshoppinglist(params){
  return new Promise(function (resolve, reject) {
      busiHttp(SHANGC.getshoppinglist, 'GET', params).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}

function handclick(params){
  return new Promise(function (resolve, reject) {
      busiHttp(SHANGC.handclick, 'GET', params).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}

function commoditydetails(id){
  return new Promise(function (resolve, reject) {
	  let URL = SHANGC.commoditydetails+"/"+id;
      busiHttp(URL, 'GET').then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}

function getItem(params){
  return new Promise(function (resolve, reject) {
      busiHttp(SHANGC.getItem, 'GET', params).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}

function customeraddress(params){
  return new Promise(function (resolve, reject) {
      busiHttp(PYTAT.customeraddress, 'GET', params).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}

function inputsite(params){
  return new Promise(function (resolve, reject) {
      busiHttp(PYTAT.inputsite, 'GET', params).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}

function retreat(params){
  return new Promise(function (resolve, reject) {
      busiHttp(PYTAT.retreat, 'POST', params).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}

function getorderlist(params){
  return new Promise(function (resolve, reject) {
      busiHttp(ORDER.getorderlist, 'GET', params,true).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}


function address(params){
  return new Promise(function (resolve, reject) {
      busiHttp(PYTAT.address, 'POST', params,false).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}

function shippingdelete(params){
  return new Promise(function (resolve, reject) {
      busiHttp(PYTAT.shippingdelete, 'POST', params,false).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}

function moren(params){
  return new Promise(function (resolve, reject) {
      busiHttp(PYTAT.moren, 'POST', params,false).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}


function getredact(id){
  return new Promise(function (resolve, reject) {
	  let URL = PYTAT.getredact+"/"+id;
      busiHttp(URL, 'GET').then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}


function addconfirm(params){
  return new Promise(function (resolve, reject) {
      busiHttp(PYTAT.addconfirm, 'POST', params,false).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}

function getserviceorder(params){
  return new Promise(function (resolve, reject) {
      busiHttp(ORDER.getserviceorder, 'POST', params,false).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}

function getmywallet(params){
  return new Promise(function (resolve, reject) {
      busiHttp(PYTAT.getmywallet, 'POST', params,false).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}

function getordeform(params){
	// let URL = ORDER.getordeform+"/"+id;
  return new Promise(function (resolve, reject) {
      busiHttp(ORDER.getordeform, 'GET',params,false).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}

function ordeformsubmit(params){
	
  return new Promise(function (resolve, reject) {
      busiHttp(PYTAT.ordeformsubmit, 'POST',params,false).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}

function radioChange(params){
	
  return new Promise(function (resolve, reject) {
      busiHttp(PYTAT.radioChange, 'POST',params,false).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}


function shoppurchase(params){
	
  return new Promise(function (resolve, reject) {
      busiHttp(SHANGC.shoppurchase, 'POST',params).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}

function getpostage(paramss){
	let URL = SHANGC.getpostage+"/"+paramss.key;
  return new Promise(function (resolve, reject) {
      busiHttp(URL, 'POST',paramss).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}

function createOrder(paramss){
	let URL = SHANGC.createOrder+"/"+paramss.key;
  return new Promise(function (resolve, reject) {
      busiHttp(URL, 'POST',paramss).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}

function cancelOrder(params){
  return new Promise(function (resolve, reject) {
      busiHttp(SHANGC.cancelOrder, 'POST',params).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}

function orderDel(params){
  return new Promise(function (resolve, reject) {
      busiHttp(SHANGC.orderDel, 'POST',params).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}

function refund(params){
  return new Promise(function (resolve, reject) {
      busiHttp(SHANGC.refund, 'POST',params).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}

function getshoppingtrolley(){
	
  return new Promise(function (resolve, reject) {
      busiHttp(SHANGC.getshoppingtrolley, 'GET').then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}


function orderConfirm(params){
	
  return new Promise(function (resolve, reject) {
      busiHttp(SHANGC.orderConfirm, 'POST',params).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}

function getlineitem(params){
 // let URL = SHANGC.getlineitem+"/"+id;
  return new Promise(function (resolve, reject) {
      busiHttp(SHANGC.getlineitem, 'GET',params,false).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}


function cartnum(params){
	
  return new Promise(function (resolve, reject) {
      busiHttp(SHANGC.cartnum, 'POST',params).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}


function homeluobo(params){
	
  return new Promise(function (resolve, reject) {
      busiHttp(ORDERS.homeluobo, 'GET',params).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}

function checkToken(params){
	
  return new Promise(function (resolve, reject) {
      busiHttp(ORDERS.checkToken, 'POST',params).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}


function tabhome(params){
	
  return new Promise(function (resolve, reject) {
      busiHttp(ORDERS.tabhome, 'POST',params).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}


function acknowledgealarm(params){
	
  return new Promise(function (resolve, reject) {
      busiHttp(ORDERS.acknowledgealarm, 'POST',params).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}

function accountinfo(params){
	
  return new Promise(function (resolve, reject) {
      busiHttp(PYTAT.accountinfo, 'GET',params).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}


function getdetails(params){
	let URL = PYTAT.getdetails+"/"+params.billId;
  return new Promise(function (resolve, reject) {
      busiHttp(URL, 'POST',params).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}

function gettype(params){
	
  return new Promise(function (resolve, reject) {
      busiHttp(PYTAT.gettype, 'GET',params).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}



function getstatus(params){
	
  return new Promise(function (resolve, reject) {
      busiHttp(PYTAT.getstatus, 'POST',params).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}

function getagreement(params){
	
  return new Promise(function (resolve, reject) {
      busiHttp(PYTAT.getagreement, 'POST',params).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}

function gotoPay(params){
	
  return new Promise(function (resolve, reject) {
      busiHttp(SHANGC.gotoPay, 'POST',params).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}

function orderTake(params){
	
  return new Promise(function (resolve, reject) {
      busiHttp(SHANGC.orderTake, 'POST',params).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}


function itemDelClick(params){
	
  return new Promise(function (resolve, reject) {
      busiHttp(SHANGC.itemDelClick, 'POST',params).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}

function maskClick(params){
	
  return new Promise(function (resolve, reject) {
      busiHttp(PYTAT.maskClick, 'POST',params).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}


function shopsearch(params){
	
  return new Promise(function (resolve, reject) {
      busiHttp(SHANGC.shopsearch, 'GET',params).then(res => {
      resolve(res)
    }).catch(err => {
        reject(err)
    })
  })
}
// function servicesDetail(id){
//   return new Promise(function (resolve, reject) {
//     let params={};
//     let URL = HOME.servicesDetail+"/"+id;
//       busiHttp(URL, 'GET', params).then(res => {
//       resolve(res)
//     }).catch(err => {
//         reject(err)
//     })
//   })
// }

// function homeSearch(params){
//   return new Promise(function (resolve, reject) {
//       busiHttp(HOME.homeSearch, 'POST', params).then(res => {
//       resolve(res)
//     }).catch(err => {
//         reject(err)
//     })
//   })
// }

export default {servicesList,login,getlist,getserve,projectclick,tabs,preserve,offline,confirms,Immediately,
getshoppinglist,handclick,commoditydetails,getItem,customeraddress,inputsite,retreat,getorderlist,address,
shippingdelete,moren,getredact,addconfirm,getserviceorder,getmywallet,getordeform,ordeformsubmit,radioChange,
shoppurchase,getpostage,getshoppingtrolley,orderConfirm,cartnum,homeluobo,checkToken,tabhome,acknowledgealarm,accountinfo,
getdetails,gettype,getstatus,getagreement,createOrder,cancelOrder,refund,getlineitem,gotoPay,orderTake,
itemDelClick,maskClick,orderDel,shopsearch,getVersion,today,wxLogin,bindwx
}